﻿// Columns
//{ key: 'AETitle', display: 'AETitle', enumVal: '', width: 50, align: 'left', hide: 0, isAllowHide: false }
var $LC = ListColumns = {
    //order
    AETitle: { key: 'AETitle', display: 'AETitle', width: 50 },
    AccessionNumber: { key: 'AccessionNumber', display: lang.term.AccessionNumber, width: langStyle.columnWidth.AccessionNumber, align: "left" },
    FullAge: { key: 'FullAge', display: lang.information.Age, width: langStyle.columnWidth.DisplayAge, type: "ageWithUnit" },
    ApplyDoctor: { key: 'ApplyDoctor', display: lang.term.ApplyDoctor, width: langStyle.columnWidth.Name },
    ApplyDoctorId: { key: 'ApplyDoctorId', display: '', hide: 1 },
    ArriveTime: { key: 'ArriveTime', display: lang.term.ArriveTime, width: langStyle.columnWidth.DateTime },
    BodyPartNames: { key: 'BodyPartNames', display: lang.term.BodyPart, width: langStyle.columnWidth.BodyPartNames },
    CheckInDoctor: { key: 'CheckInDoctor', display: lang.term.CheckInDoctorName, width: langStyle.columnWidth.Name },
    CheckInDoctorId: { key: 'CheckInDoctorId', display: '', hide: 1 },
    ClinicalNumber: { key: 'ClinicalNumber', display: lang.term.ClinicalNumber, width: langStyle.columnWidth.ClinicalNumber },
    CreateDateTime: { key: 'CreateDateTime', display: lang.term.CreateDateTime, width: langStyle.columnWidth.DateTime },
    DateOfBirth: { key: 'DateOfBirth', display: lang.information.DateOfBirth, width: langStyle.columnWidth.DateOfBirth },
    IsMultiple: { key: 'IsMultiple' },
    DeviceId: { key: 'DeviceId', display: '', hide: 1 },
    DeviceName: { key: 'DeviceName', display: lang.term.Device, width: langStyle.columnWidth.DeviceName },
    DisplayAge: { key: 'DisplayAge', display: lang.information.Age, width: langStyle.columnWidth.DisplayAge, type: "ageWithUnit" },
    ExamRoom: { key: 'ExamRoom', display: lang.term.ExamRoom, width: langStyle.columnWidth.ExamRoom },
    FromOtherNode: {
        key: "FromOtherNode", display: lang.term.IsCurrentNode, width: langStyle.columnWidth.RegionAssist, render: function (rec, rowIdx, val, col) {            
            if (val == null || val == undefined || !val) {
                return lang.term.Yes;
            }
            return lang.term.No;
        }
    },
    ExamConfirm: {
        key: 'OrderFlags', display: lang.term.ExamConfirm, width: langStyle.columnWidth.ExamConfirm, render: function (rec, rowIdx, val, col) {
            if (val == null || val == undefined || ((val & 2) == 2) || ((val & 1) !== 1)) {
                return lang.term.Yes;
            }
            return lang.term.No;
        }
    },
    Gender: { key: 'Gender', display: lang.information.Gender, width: langStyle.columnWidth.Gender, enumVal: 'Gender' },
    GloablePatientId: { key: 'GloablePatientId', display: lang.term.GloablePatientId, width: langStyle.columnWidth.GloablePatientId },
    Id: { key: 'Id', display: '', hide: 1 },
    PatientMergeId: { key: 'PatientMergeId', display: '', hide: 1 },
    InpatientNumber: { key: 'InpatientNumber', display: lang.term.InpatientNumber, width: langStyle.columnWidth.InpatientNumber },
    MedicalRecordNumber: { key: 'MedicalRecordNumber', display: lang.term.MedicalRecordNumber, width: langStyle.columnWidth.InpatientNumber },
    VisitSerialNumber: { key: 'VisitSerialNumber', display: lang.term.VisitSerialNumber, width: langStyle.columnWidth.InpatientNumber },    
    InHospitalCount: { key: 'InHospitalCount', display: lang.term.InHospitalCount, width: langStyle.columnWidth.InHospitalCount },
    IsVIP: { key: 'IsVIP', display: '', width: 50 },
    IsFromHIS: { key:"IsFromHIS",display:"",hide:1},
    LastUpdateDateTime: { key: 'LastUpdateDateTime', display: lang.term.LastUpdateDateTime, width: langStyle.columnWidth.DateTime },
    ModalityId: { key: 'ModalityId', display: '', hide: 1 },
    ModalityName: { key: 'ModalityName', display: lang.term.Modality, width: langStyle.columnWidth.ModalityName },
    Name: { key: 'Name', display: lang.information.Name, width: langStyle.columnWidth.Name },
    OrderDoctor: { key: 'OrderDoctor', display: lang.term.ApplyDoctor, width: langStyle.columnWidth.Name },
    OrderDoctorId: { key: 'OrderDoctorId', display: '', hide: 1 },
    OrderId: { key: 'OrderId', display: '', hide: 1 },
    OrginalStatus: { key: 'Status', display: '', width: 1, isOriginal: true },
    PatientID: { key: 'PatientID', display: '', width: 50, hide: 1 },
    RegionAssist: { key: "RegionAssist", display: lang.term.RegionAssist, width: 100, render: function (rec, rowIdx, val, col) { return val ? lang.command.Yes : lang.command.No; } },
    IsSimilarity: {
        key: "IsSimilarity", display: lang.term.IsSimilarity, width: 90, render: function (rec, rowIdx, val, col) {
            return val ? "<div class=\"l-icon-similarity\" style=\"height:16px;\" title=\"" + lang.tips.HaveSimilarity + "\"/>" : "";
        }
    },
    ServerNode:{ key: "ServerNode", display: lang.term.Hospital, width: 100, align: 'center' },
    Similarity: {
        key: "Similarity", display: lang.term.Similarity, width: 130, type: "float", render: function (rec, rowIdx, val, col) {
            var data = val - 0;
            var colorStyle = "";
            if (data >= 90) {
                colorStyle = "style=\"color:#0000FF;\"";
            } else if (data < 60) {
                colorStyle = "style=\"color:#FF0000;\"";
            }
            return "<span " + colorStyle + ">" + (data == 101 ? lang.msg.PatientMsg20 : (data.toFixed(2) + "%")) + "</span>";
        }
    },
    IsMerged: {
        key: "IsMerged", isAllowHide: false, display: lang.term.IsMerged, width: 130, align: 'center', render: function (rec, rowIdx, val, col) {
            return val > 0 ? "<div class=\"l-icon-merged\" style=\"height:16px;width:16px;display:inline-block;\" title=\"" + lang.tips.PatientMerged + "\"/>" : "";
        }
    },
    GlobalPatientIdWithTag: {
        key: 'GlobalPatientId', display: lang.term.GloablePatientId,
        width: 190, render: function (rec, rowIdx, val, col) {
            return "{0}{1}{2}".format(
                val,
                rec.IsSimilarity ? "<div class=\"l-icon-similarity\" style=\"height:16px;width:16px;display:inline-block;margin:0px 8px;\" title=\"" + lang.tips.HaveSimilarity + "\"/>" : "",
                rec.IsMerged > 0 ? "<div class=\"l-icon-merged\" style=\"height:16px;width:16px;display:inline-block;margin:0px 8px;\" title=\"" + lang.tips.PatientMerged + "\"/>" : ""
            );
        }
    },
    BasePatient: {
        key: "BasePatient", display: "", width: 36, isSort: false, isAllowHide: false, render: function (rec, rowIdx, val, col) {
            return val ? "<div class=\"l-icon-basePatient\" style=\"height:16px;margin-top:4px;\" title=\"" + lang.tips.BasePatient + "\"/>" : "<input type=\"checkbox\" class=\"cus_checkbox\" style=\"margin-top:4px;\"/>";
        }
    },
    CheckboxColoum: {
        key: "CheckboxColoum", display: "<input type=\"checkbox\" class=\"cus_checkbox\" data-action='chkAll' style=\"margin-top:4px;\"/>",
        isSort: false, isAllowHide: false, width: 36, render: function (rec, rowIdx, val, col) {
            return "<input type=\"checkbox\" class=\"cus_checkbox\" style=\"margin-top:4px;\"/>";
        }
    },
    DiagnosisGroup: { key: "DiagnosisGroup", display: lang.term.DiagnosisGroup, width: langStyle.columnWidth.Name },
    PatientName: { key: 'PatientName', display: lang.information.Name, width: langStyle.columnWidth.Name },
    PatientNote: { key: "Note", display: lang.term.Note, width: langStyle.columnWidth.Note },
    PatientType: { key: 'PatientType', display: lang.term.PatientType, width: langStyle.columnWidth.PatientType, enumVal: 'PatientType' },
    PatientIdentityName: { key: 'PatientIdentityName', display: lang.term.PatientIdentityName, width: langStyle.columnWidth.Name },
    RegisterTime: { key: 'RegisterTime', display: lang.term.RegisterTime, width: langStyle.columnWidth.DateTime },
    ScheduledStartTime: { key: 'ScheduledStartTime', display: lang.term.ScheduleDatetime, width: langStyle.columnWidth.DateTime },
    Status: { key: 'Status', display: lang.status.Status, width: langStyle.columnWidth.Status, align: "left", isAllowHide: true, enumVal: 'OrderStatus' },
    ScheduledTimePeriod: {key: "ScheduledTimePeriod", display: lang.term.SchedulePeriod, width: 210, align: "left"},
    TimePeriod: { key: 'TimePeriod', display:"", width: 110 },
    //PatientInfoHistory
    PatientInfoModifyType: {
        key: "ModifyType", display: lang.term.OperationType, width: 120, render: function (rec, rowIdx, val, col) {
            var tpKey = $.trim(val);
            return tpKey != "" ? $.trim(lang.ConstData.PatientInfoModifyType[tpKey]) : "";
        }
    },
    PatientInfoModifyStaff: { key: "OperatorName", display: lang.term.OperationStaff, width: 120 },
    PatientInfoModifyDateTime: { key: "CreateDateTime", display: lang.term.OperationDateTime, width: langStyle.columnWidth.DateTime },
    PatientInfoModifyItems: {
        key: "PatientContent",align:'left', display: lang.term.ModifyItems, width: 240, render: function (rec, rowIdx, val, col) {
            try {
                var obj = $.parseJSON(val);
                var changedProperties = [];
                $(obj).each(function () {
                    var nm = $.trim(this.Name);
                    if (nm != "") {
                        var mpValue = lang.ConstData.PatientProperty[nm];
                        if (mpValue) {
                            changedProperties.push(mpValue);
                        } else {
                            changedProperties.push(nm);
                        }
                    }
                });
                return "<span title=\"{0}\">{0}</span>".format(changedProperties.join(" , "));
            } catch (e) {
            }
            return "";
        }
    },
    //report
    Accord: { key: 'Accord', display: '', width: 50 },
    Age: { key: 'Age', display: lang.information.Age, width: langStyle.columnWidth.DisplayAge },
    ApproveDatetime: { key: 'ApproveDatetime', display: lang.term.ApproveDatetime, width: langStyle.columnWidth.DateTime },
    ApproveDoctor: { key: 'ApproveDoctor', display: lang.term.ApproveDoctor, width: langStyle.columnWidth.Name },
    ApproveDoctorId: { key: 'ApproveDoctorId', display: '', width: 50 },
    ExecDoctorName: { key: 'ExecDoctorName', display: lang.term.ExecDoctorName, width: langStyle.columnWidth.Name },
    ExecDoctorId: { key: 'ExecDoctorId', display: '', width: 50 },
    Birthday: {
        key: 'Birthday', display: lang.information.DateOfBirth, width: 150, render: function (rec, rowIdx, val, col) {
            return (val == null || val == undefined) ? "" : val.split(" ")[0];
        }
    },
    BodyParts: { key: 'BodyParts', display: lang.term.BodyPart, width: langStyle.columnWidth.BodyParts },
    Checkitems: { key: 'Checkitems', display: lang.term.CheckItem, width: langStyle.columnWidth.Checkitems },
    CheckItems: { key: 'CheckItems', display: lang.term.CheckItem, width: langStyle.columnWidth.Checkitems },
    Device: { key: 'Device', display: lang.term.Device, width: 160 },
    FilmingRank: { key: 'FilmingRank', display: lang.term.FilmingRank, width: 80 },
    FilmingFailedReason: {
        key: 'FilmingFailedReason', display: lang.term.FilmingFailedReason, width: 150,render: function (rec, rowIdx, val, col) {
            if (rec["FilmingRank"] && rec["FilmingFailedReason"]!="") {
                return "<span title=\"{0}\">{0}</span>".format(ris_utils.htmlEncode(val));
            }
            return "";
        }
    },
    Filminger: { key: 'Filminger', display: '', width: 50 },
    Forum: { key: 'Forum', display: '', width: 50 },
    GlobalPatientId: { key: 'GlobalPatientId', display: lang.term.GloablePatientId, width: langStyle.columnWidth.GloablePatientId },
    Hospital: { key: 'Hospital', display: lang.term.Hospital, width: 250 },
    HospitalId: { key: 'HospitalId', display: "", hide: 1 },
    ImageCount: { key: 'ImageCount', display: lang.term.ImageCount, width: 100, type: 'float' },
    LastImageDateTime: { key: 'LastImageDateTime', display: lang.term.LastImageDateTime, width: 170 },
    QueueNumber: { key: 'QueueNumber', display: lang.term.QueueNumber, width: 100, type: 'int' },
    IsLock: { key: 'IsLock', display: '', width: 50 },
    IsPositive: { key: 'IsPositive', display: lang.term.IsPositive, width: langStyle.columnWidth.IsPositive },
    IsPrintFilm: {key: 'IsPrintFilm', display: lang.term.FilmPrintStatus, width: 130, render: function (rec, rowIdx, val, col) {
            if (val === true) {
                return lang.status.Print;
            } else if (val === false) {
                return lang.status.UnPrint;
            } else {
                return lang.term.Unknown;
            }
    }},
    IsReportPrinted: { key: 'IsReportPrinted', display: '', width: 50 },
    ICDCode: { key: 'ICDCode', display: 'ICD Code', width: 100 },
    Keywords: { key: 'Keywords', display: lang.term.ReportKeywords, width: langStyle.columnWidth.Keywords },
    Impression: { key: 'Impression', display: lang.term.Diagnosis, width: 420, align: "left",
        render: function(rec, rowIdx, val) {
            return '<span title="' + $.trim(val) + '">' + (val && val.length > 32 ? val.substring(0, 32) : $.trim(val)) + '</span>';
        }
    },
    Modality: { key: 'Modality', display: lang.term.Modality, width: langStyle.columnWidth.ModalityName },
    OrderDepartment: { key: 'OrderDepartment', display: lang.term.ApplyDepartment, width: langStyle.columnWidth.OrderDepartment },
    OrginalReportStatus: { key: 'ReportStatus', display: '', width: 1, isOriginal: true },
    PatientId: { key: 'PatientId', display: '', width: 50 },
    PatientSpellName: { key: 'PatientSpellName', display: '', width: 50 },
    PrintDateTime: { key: 'PrintDateTime', display: '', width: 50 },
    PrintDoctor: { key: 'PrintDoctor', display: '', width: langStyle.columnWidth.Name },
    PrintDoctorId: { key: 'PrintDoctorId', display: '', width: 50 },
    PublishDateTime: { key: 'PublishDateTime', display: '', width: langStyle.columnWidth.DateTime },
    PublishDoctor: { key: 'PublishDoctor', display: '', width: langStyle.columnWidth.Name },
    PublishDoctorId: { key: 'PublishDoctorId', display: '', width: 50 },
    ReportCreator: { key: 'ReportCreator', display: lang.term.ReportDoctor, width: langStyle.columnWidth.Name },
    ReportCreatorId: { key: 'ReportCreatorId', display: '', width: 50 },
    AssignedReportDoctor: { key: 'AssignedReportDoctor', display: lang.term.AssignedReportDoctor, width: langStyle.columnWidth.AssignedReportDoctor },//分配的报告医师
    AssignedApproveDoctor: { key: 'AssignedApproveDoctor', display: lang.term.AssignedApproveDoctor, width: langStyle.columnWidth.AssignedReportDoctor },//分配的审核医师
    AssignedReportDoctorId: { key: 'AssignedReportDoctorId', display: '', width: 50 },
    AssignedApproveDoctorId: { key: 'AssignedApproveDoctorId', display: '', width: 50 },
    ReportId: { key: 'ReportId', display: '', width: 50 },
    ReportStatus: { key: 'ReportStatus', display: lang.status.Status, width: langStyle.columnWidth.Status, enumVal: 'ReportStatus' },
    ReportTimeSpace: { key: 'ReportTimeSpace', display: '<img src="{0}" title="{1}" />'.format(alarm_clock, lang.term.ReportTimeSpace), width: langStyle.columnWidth.ReportTimeSpace },
    ReportUrl: { key: 'ReportUrl', display: '', width: 50 },
    ScheduleProcedureId: { key: 'ScheduleProcedureId', display: '', width: 50 },
    StudyDateTime: { key: 'StudyDateTime', display: lang.information.StudyDate, width: langStyle.columnWidth.DateTime },
    StudyInstanceUId: { key: 'StudyInstanceUId', display: '', width: 50 },
    SubmitDateTime: { key: 'SubmitDateTime', display: '', width: 50 },
    SubmitDoctor: { key: 'SubmitDoctor', display: lang.term.ReportDoctor, width: langStyle.columnWidth.Name },
    SubmitDoctorId: { key: 'SubmitDoctorId', display: '', width: 50 },
    Track: { key: 'Track', display: '', width: 50 },
    Tracker: { key: 'Tracker', display: '', width: langStyle.columnWidth.Name },
    VipReportDoctorId: { key: 'VipReportDoctorId', display: '', width: 50 },
    VisitId: { key: 'VisitId', display: '', width: 50 },
    WorkGroup: { key: 'WorkGroup', display: '', width: 50 },
    UploadToRegionTime: { key: 'UploadToRegionTime', display: lang.term.UploadTime, width: 160 },
    ReportAudioCount: {
        key: 'ReportAudioCount', display: '<img src="{0}" title="{1}" />'.format(report_audio, lang.term.ReportAudio), width: 36, render: function (rec, rowIdx, val, col) {
            var data = val - 0;
            return data > 0 ? "<div class=\"l-icon-audio l-icon-item\" style=\"height:16px;\"/>" : "";
        }
    },
    IsCritical: {
        key: "IsCritical", display: lang.term.critical, width: 100, render: function (rec, rowIdx, val, col) {
            return val ? "<span class=\"red\">{0}</span>".format(lang.status.CriticalCritical) : lang.status.CriticalNormal;
        }
    },
    ReportSeq: { key: 'ReportSeq', display: lang.term.ReportSeq, width: 100, type: 'int'},
    ReportImageReader: { key: "ImageReaderName", display: lang.term.ImageReader, width: 120 },
    ImageReaderId: { key: "ImageReaderId", display: "", width: 50 },
    ReportQuality: {
        key: "ReportQuality", display: lang.term.ReportQuality, width: 120, render: function (rec, rowIdx, val, col) {
            return ($.trim(val).length > 5) ? lang.status.QualityEvaluate : "";
        }
    },
    ReportFollowUp: {
        key: "ReportFollowUp", display: lang.term.ReportFollowUp, width: 150, render: function (rec, rowIdx, val, col) {
            if (rec["NeedFollowUp"]) {
                return ($.trim(val).length > 5) ? lang.status.ReportFollowUp : "";
            }
            return "";
        }
    },
    NeedFollowUp: { key: "NeedFollowUp", display: lang.term.FollowUp, width: 120, render: function (rec, rowIdx, val) { return val ? lang.term.NeedFollowUp : ""; } },
    ContagionName: { key: "ContagionName", display: lang.term.ReportContagion, width: 150 },
    //Perform
    IsMatch: { key: 'IsMatch', display: lang.status.MatchStatus, width: langStyle.columnWidth.IsMatch },
    OrginalIsMatch: { key: 'IsMatch', display: '', width: 1, isOriginal: true },
    //Procedure
    Operate: { key: 'Operate', display: lang.command.Operate, width: 80 },
    ProcedureCheckItem: { key: 'CheckItemId', display: lang.term.CheckItem, width: 160 },
    ContrastMedium: { key: 'ContrastName', display: lang.term.ContrastMedium, width: 80 },
    Dosage: { key: 'ContrastDose', display: lang.term.Dosage, width: 40 },
    ExposalAmount: { key: 'ExposalAmount', display: lang.term.ExposalAmount, width: 60 },
    FilmAmount: { key: 'FilmAmount', display: lang.term.FilmAmount, width: 90 },
    FilmSpec: { key: 'FilmSpec', display: lang.term.FilmSpec, width: 80 },
    ImageAmount: { key: 'ImageAmount', display: lang.term.ImageAmount, width: 60 },
    Fee: { key: 'Fee', display: lang.term.Fee, width: 60 },
    Address: { key: 'Address', display: lang.information.Address, width: 180 },
    IDCard: { key: 'IDCard', display: lang.information.IDNumber, width: 180 },
    SocietyNumber: { key: 'SocietyNumber', display: lang.information.SocietyNumber, width: 100 },
    BedNumber: { key: 'BedNumber', display: lang.term.BedNumber, width: 100 },
    Telephone: { key: 'Telephone', display: lang.information.Telephone, width: 110 },
    PDStatus: { key: 'PDStatus', display: lang.term.PDStatus, width: 160, enumVal: 'PDStatus' },
    TotalCheckFee: { key: 'TotalCheckFee', display: lang.term.TotalCheckFee, width: 160 },
    TotalFilmFee: { key: 'TotalFilmFee', display: lang.term.TotalFilmFee, width: 160 },
    TotalMaterialFee: { key: 'TotalMaterialFee', display: lang.term.TotalMaterialFee, width: 160 },
    TotalFee: { key: 'TotalFee', display: lang.term.TotalFee, width: 160 },
    EmergencyDegree: { key: 'EmergencyDegree', display: lang.term.EmergencyDegree, width: langStyle.columnWidth.EmergencyDegree, enumVal: 'EmergencyDegree', Type: 'floatInAttribute' },
    DoctorAdviceType: { key: 'DoctorAdviceType', display: lang.term.DoctorAdviceType, width: langStyle.columnWidth.DoctorAdviceType, enumVal: 'DoctorAdviceType', type:"html"},
    ImageAssociationLogColumns: [
        { display: lang.term.OriginalGloablePatientId, key: 'OriginalPatientId', width: 130 },
        { display: lang.term.OriginalPatientName, key: 'OriginalPatientName', width: 140 },
        { display: lang.term.RevisedGloablePatientId, key: 'RevisedPatientId', width: 130 },
        { display: lang.term.RevisedPatientName, key: 'RevisedPatientName', width: 140 },
        { display: lang.term.OperationDateTime, key: 'DateCreate', width: 160 },
        { display: lang.command.Operate, key: 'OperationType', width: 120 },
        { display: lang.term.OperaterName, key: 'OperatorName', width: 140 }
    ],
    StudyDescription: { key: 'StudyDescription', display: lang.term.CheckItem, width: 200 },
    ExamineDateTime: { key: 'StudyTime', display: lang.term.ExamineDateTime, width: 200 },
    TemplateName: { key: 'Name', display: lang.term.TemplateName, width: 240, align: "left" },
    MnemonicCode: { key: 'MnemonicCode', display: lang.term.MnemonicCode, width: 120 },
    ApplyGender: { key: 'Gender', display: lang.term.ApplyGender, width: 120 },
    BodyPartName: { key: 'BodyPartName', display: lang.term.BodyPart, width: 200, align: "left" },
    DiseaseName: { key: 'DiseaseName', display: lang.term.Disease, width: 200, align: "left" },
    TemplateBodypartName: { key: 'TemplateBodypartName', display: lang.term.TemplateBodypart, width: 200, align: "left" },
    CommonName: { key: 'Name', display: lang.term.Name, width: 185, align: "left" },
    DiagnosisAssignmentType: { key: 'AssignmentType', display: lang.term.DiagnosisAssignmentType, width: 160 },
    DiagnosisCheckItems: { key: 'CheckItems', display: lang.term.CheckItem, width: 160,align:"left" },
    DiagnosisStartDateDiff: { key: 'StartDateDiff', display: '', hide: 1 },
    DiagnosisEndDateDiff: { key: 'EndDateDiff', display: '', hide: 1 },
    DiagnosisStartTime: {
        key: 'StartTime', display: lang.term.DiagnosisStartTime, width: 120, render: function (rowdata, rowindex, val) {
            var diff = $.trim(rowdata["StartDateDiff"]);            
            if (diff != "") {
                if (diff.indexOf("-") > -1) { 
                    return lang.formatter.DiagnosisPrevTimeFmt.format(diff.replace("-", ""), val);
                } else {
                    return lang.formatter.DiagnosisAfterTimeFmt.format(diff, val);
                }
            }
            return "";
        }, align: "left"
    },
    DiagnosisEndTime: {
        key: 'EndTime', display: lang.term.DiagnosisEndTime, width: 120, render: function (rowdata, rowindex, val) {
            var diff = $.trim(rowdata["EndDateDiff"]);
            if (diff != "") {
                if (diff.indexOf("-") > -1) {
                    return lang.formatter.DiagnosisPrevTimeFmt.format(diff.replace("-", ""), val);
                } else {
                    return lang.formatter.DiagnosisAfterTimeFmt.format(diff, val);
                }
            }
            return "";
        }, align: "left"
    },
    DiagnosisModalities: { key: 'Modalities', display: lang.term.Modality, width: 160 },
    DiagnosisMembers: { key: 'Members', display: lang.term.ReportDoctor, width: 160 },
    DiagnosisDevices: { key: 'Devices', display: lang.term.Device, width: 220 },
    DiagnosisBodyParts: { key: 'BodyParts', display: lang.term.BodyPart, width: 220, align:"left" },
    DiagnosisStatus: { key: 'Status', display: lang.status.Status, width: 80, render: function (rowdata) { return (rowdata.Status) ? lang.ConstData.Enable : lang.ConstData.Disable; } },
    PatientTypes: { key: 'PatientTypes', display: lang.term.PatientType, width: 180, enumVal: 'PatientTypes'},
    StatisticsCategoryName: { key: 'CategoryName', display: lang.term.StatisticsCategories, width: 165 },
    StatisticsIsPublic: { key: 'IsPublic', display: lang.msg.StatisticMsg15, width: 125 },
    StatisticsOperaterName: { key: 'CreateDoctorName', display: lang.term.OperaterName, width: 135 },
    StatisticsCreateDateTime: { key: 'CreateDateTime', display: lang.term.CreateDateTime, width: 200 },
    Sort: { key: 'Sort', display: lang.term.SortNumber, width: 60, type: "int" },
    TemplateType: {
        key: 'IsSystemTemplate', display: lang.term.TemplateType, width: 200, render: function (rowdata, rowindex) {
            return rowdata.IsSystemTemplate ? lang.ConstData.TemplateTypeSystem: lang.ConstData.TemplateTypeUser;
        }
    },
    TemplateCategory: {
        key: 'ModalityTemplateType', display: lang.term.ModalityTemplateType, width: 200, render: function (rowdata, rowindex, val) {
            val = val ? val : "Report";
            if (lang.ConstData.ModalityTemplateType.hasOwnProperty(val)) {
                return lang.ConstData.ModalityTemplateType[val];
            }
            return val;
        }
    },
    TemplateStatus: {
        key: 'IsEnabled', display: lang.term.status, width: 100, render: function (rowdata, rowindex) {
            return (rowdata.IsEnabled ? lang.ConstData.Enable : lang.ConstData.Disable);
        }
    },
    AuditColumns: {
        Actioner: { key: 'Actioner', display: lang.term.OperationStaff, width: langStyle.columnWidth.Name },
        OperateTime: { key: 'OperateTime', display: lang.term.OperationDateTime, width: 160 },
        ActionName: { key: 'ActionName', display: lang.term.OperationType, width: 150 },
        UserLogin: { key: 'UserLogin', display: lang.term.UserLogin, width: 200 },
        CreateUser: { key: 'CreateUser', display: lang.term.CreateUser, width: 200 },
        ModifyUser: { key: 'ModifyUser', display: lang.term.ModifyUser, width: 200 },
        DeleteUser: { key: 'DeleteUser', display: lang.term.DeleteUser, width: 200 },
        ChangePassword: { key: 'ChangePassword', display: lang.term.ChangePassword, width: 200 },
        GloablePatientId: { key: 'GloablePatientId', display: lang.term.GloablePatientId, width: langStyle.columnWidth.GloablePatientId },
        PatientName: { key: 'PatientName', display: lang.term.PatientName, width: langStyle.columnWidth.Name },
        Gender: { key: 'Gender', display: lang.information.Gender, width: langStyle.columnWidth.Gender },
        Birthday: { key: 'Birthday', display: lang.information.DateOfBirth, width: langStyle.columnWidth.DateOfBirth },
        InpatientNumber: { key: 'InpatientNumber', display: lang.term.InpatientNumber, width: langStyle.columnWidth.AccessionNumber },
        ClinicalNumber: { key: 'ClinicalNumber', display: lang.term.ClinicalNumber, width: langStyle.columnWidth.ClinicalNumber },
        AccessionNumber: { key: 'AccessionNumber', display: lang.term.AccessionNumber, width: langStyle.columnWidth.AccessionNumber },
        CheckItems: { key: 'CheckItems', display: lang.term.CheckItem, width: langStyle.columnWidth.Checkitems },
        StudyID: { key: 'StudyID', display: lang.term.StudyID, width: 200 },
        Device: { key: 'Device', display: lang.information.Device, width: langStyle.columnWidth.DeviceName },
        Findings: { key: 'Findings', display: lang.information.Findings, width: 200, render: function(rec,rowIdx,val) {
            if (val) {
                return (val.length > 20) ? ('<span title="' + val + '">' + val.substring(0, 20) + '...</span>') : val;
            }
            return "";
        } },
        Impression: {
            key: 'Impression', display: lang.information.Impression, width: 200, render: function (rec, rowIdx, val) {
                if (val) {
                    return (val.length > 20) ? ('<span title="' + val + '">' + val.substring(0, 20) + '...</span>') : val;
                }
                return "";
            }
        },
        Hospital: { key: 'HospitalName', display: lang.term.Hospital, width: 200 },
        ClientIP: { key: 'ClientIP', display: lang.term.ClientIP, width: 120 },
        AssignedDoctor: { key: 'AssignedDoctor', display: lang.term.AssignedDoctor, width: 200 }
    },
    HisColumns: {
        Details: { display: lang.term.SymposiumDetails, key: 'details', width: 60 },
        HisOrderRequestDate: { display: lang.term.HisOrderRequestDate, key: 'HisOrderRequestDate', width: langStyle.columnWidth.HisOrderRequestDate },
        Name: { display: lang.information.Name, key: 'Name', width: 80 },
        CheckItems: {
            display: lang.term.CheckItems, key: 'CheckItems', width: 120, render: function (rowdata) {
                var checkItems = rowdata.HisExamName || "";
                if (rowdata.HisExamName && rowdata.HisExamName.length > 8)
                    checkItems = checkItems.substring(0, 8);
                return "<span title='" + rowdata.HisExamName + "'>" + checkItems + "</span>";
            }
        },
        Fee: { display: lang.term.Fee, key: 'TotalFee', width: langStyle.columnWidth.Fee, type: 'float' },
        HisOrderCode: { display: lang.term.HisOrderCode, key: 'HisOrderCode', width: 120 },
        GlobalPatientId: { display: lang.term.GloablePatientId, key: "GlobalPatientId", width: 150 },
        Gender: { display: lang.information.Gender, key: "GenderDisplayName", width: 50 },
        ApplyDepartment: { display: lang.term.ApplyDepartment, key: "ApplyDepartmentName", width: 100 },
        ApplyDoctor: { display: lang.term.ApplyDoctor, key: "ApplyDoctorName", width: 100 },
        ScheduleDateTime: { display: lang.term.ScheduleDatetime, key: "ScheduleDateTime", width: 200 },
        Birthday: { key: 'DateOfBirth', display: lang.information.DateOfBirth, width: langStyle.columnWidth.DateOfBirth },
        PatientIdentity: { key: 'PatientIdentityName', display: lang.term.PatientIdentity, width: 100 },
        PatientType: { key: 'PatientTypeDisplayName', display: lang.information.PatientType, width: 100 },
        ClinicalDiagnosis: { key: 'ClinicalDiagnosis', display: lang.term.ClinicalDiagnosis, width: 200, render: function (rowdata) { var item = rowdata.ClinicalDiagnosis;var text = "";
            if (item && item.length > 12) {
                text = item.substring(0,12)+"...";
            }; return "<span title='" + item + "'>" + text + "</span>"; } }
    }
};

// Special Columns
var $LC_S = ListColumnsSpecified = {
    getPatientChangedColumn: function(colJson,prop) {
        var obj = (colJson == null || colJson == undefined)?null: colJson.parseJsonToObject();
        if (obj == null) {
            return '';
        }
        var html = '';

        var getChangedHtml = function(name,value) {
            var f = {
                Gender: function (val) { return EnumHelper.getName(val, "Gender"); },
                NationId: function (val) { return EnumHelper.getNationNameById(val); },
                DateOfBirth: function (val) { return $.trim(val).replace(/ \d{1,}:\d{1,}:\d{1,}(\.\d{1,})?$/g, "").replace(/\//g, "-") }
            };
            var fieldName = name;
            var fieldValue = value;
            if (lang.ConstData.PatientProperty.hasOwnProperty(name)) {
                fieldName = lang.ConstData.PatientProperty[name];
            }

            if (f.hasOwnProperty(name)) {
                fieldValue=f[name](value);
            }
            return '<span style="display:block">{0} : {1}</span>'.format(fieldName, ris_utils.htmlEncode(fieldValue));
        };

        $(obj).each(function (i, ele) {
            html += getChangedHtml(ele.Name,ele[prop]);
        });
        return html;
    },
    ReportIcons: {
        display: '<img src="{0}" title="{1}" />'.format(report_lock, lang.msg.LockMsg8), isAllowHide: false, width: 35,
        render: function (row) {
            var icons = '';
            if (row.IsLock) icons += '<img style="margin-top:3px;" src="../../Content/site/imgs/lock.png" title="{0}"/>'.format(lang.msg.LockMsg5);
            // 已打印 不显示上锁
            if (row.IsReportPrinted) icons = '<img style="margin-top:3px;" src="../../Content/site/imgs/report_print.png" title="{0}"/>'.format(lang.msg.LockMsg7);
            // vip 不显示上锁
            if (row.IsVIP) icons = '<img style="margin-top:3px;" src="../../Content/site/imgs/vip.png" title="{0}"/>'.format(lang.msg.LockMsg6);
            return icons;
        }
    },
    ReportListIcons4RegionOrder: {
        key: "ReportListIcons4RegionOrder",
        display: lang.term.ReportMark,
        isAllowHide: false,
        align: 'left',
        width: 80,
        render: function (row) {
            var icons = [];
            var field = {
                ReportStatus: "OrginalReportStatus"
            };

            var finishedRptStatus = { Publish: 1, Verify: 1 };
            var iconLink = "<a href=\"{1}\" title=\"{2}\"><span class=\"l-icon-item {0}\"></span></a>";

            if (row.hasOwnProperty("StudyInstanceUId") && row.hasOwnProperty("OrginalAccessionNumber") && row.hasOwnProperty("OrginalIsMatch") && row.OrginalIsMatch && $.trim(row.StudyInstanceUId) !== "") {
                icons.push(iconLink.format("l-icon-image", "javascript:pacsImageHelper.viewImagesByUID('{0}','{1}')".format(row.StudyInstanceUId, row.OrginalAccessionNumber), lang.titles.ViewImage));
            }

            if (row.hasOwnProperty("ReportId") && row.hasOwnProperty(field.ReportStatus) && finishedRptStatus.hasOwnProperty(row[field.ReportStatus])) {
                icons.push(iconLink.format("l-icon-report", "javascript:pageRender.viewReport('{0}')".format(row.ReportId), lang.titles.ViewReport));
            }
            return icons.join("");
        }
    },
    ReportListIcons: {
        key: "ReportListIcons",
        display: lang.term.ReportMark,
        isAllowHide: false,
        align: 'left',
        width: 140,
        render: function (row) {
            var icons = [];
            var field = {
                ReportAudioCount: "ReportAudioCount",
                IsLock: "IsLock",
                IsReportPrinted: "IsReportPrinted",
                IsVIP: "IsVIP",
                ReportTimeSpace: "ReportTimeSpace",
                ReportStatus:"OrginalReportStatus"
            };
            
            var finishedRptStatus = { Publish: 1, Verify: 1 };
            var iconFmt = "<span class=\"l-icon-item {0}\"></span>";
            var iconText = row.hasOwnProperty(field.ReportTimeSpace) ? "<span class=\"l-icon-item l-icon-with-text {0}\"></span>" : iconFmt;
            var iconLink = "<a href=\"{1}\" title=\"{2}\"><span class=\"l-icon-item {0}\"></span></a>";
            
            if (row.hasOwnProperty("StudyInstanceUId") && row.hasOwnProperty("OrginalAccessionNumber") && row.hasOwnProperty("OrginalIsMatch") && row.OrginalIsMatch && $.trim(row.StudyInstanceUId) !== "") {
                icons.push(iconLink.format("l-icon-image", "javascript:pacsImageHelper.viewImagesByUID('{0}','{1}')".format(row.StudyInstanceUId, row.OrginalAccessionNumber), lang.titles.ViewImage));
            }

            if (row.hasOwnProperty("ReportId") && row.hasOwnProperty(field.ReportStatus) && finishedRptStatus.hasOwnProperty(row[field.ReportStatus])) {
                icons.push(iconLink.format("l-icon-report", "javascript:pageRender.viewReport('{0}')".format(row.ReportId), lang.titles.ViewReport));
            }

            //ReportAudioCount
            if (row.hasOwnProperty(field.ReportAudioCount) && (row[field.ReportAudioCount] - 0) > 0) {
                icons.push(iconText.format("l-icon-audio"));
            }

            //lock
            if (row.hasOwnProperty(field.IsLock) && row[field.IsLock]) {
                icons.push(iconFmt.format("l-icon-locked"));
            }

            //printed
            if (row.hasOwnProperty(field.IsReportPrinted) && row[field.IsReportPrinted]) {
                icons.push(iconFmt.format("l-icon-report-print"));
            }

            //isVip
            if (row.hasOwnProperty(field.IsVIP) && row[field.IsVIP]) {
                icons.push(iconFmt.format("l-icon-isVip"));
            }
            
            //show timeSpace
            if (row.hasOwnProperty(field.ReportTimeSpace)) {
                icons.push("<span style=\"display:inline-block;line-height:28px;padding:0 2px;\">{0}</span>".format(row[field.ReportTimeSpace]));
            }
            return icons.join("");
        }
    },
    Patient_OriginalValue: {
        key: 'PatientContent', align: 'left', display: lang.term.OriginalValue, width: 200, render: function (rec, rowIdx, val, col) {
            return $LC_S.getPatientChangedColumn(val,"OldValue");
        }
    },
    Patient_NowValue: {
        key: 'PatientContent', align: 'left', display: lang.term.NowValue, width: 200, render: function (rec, rowIdx, val, col) {
            return $LC_S.getPatientChangedColumn(val,"NewValue");
        }
    }
};

var $LConfig = {
    PatientList: {
        rows: [
            $LC.GlobalPatientId, $LC.Name,
            $LC.Gender, $LC.FullAge, $LC.Id, $LC.LastUpdateDateTime, $LC.DateOfBirth, $LC.IDCard, $LC.SocietyNumber,
            $LC.Telephone, $LC.Address,
            $LC.IDCard, $LC.SocietyNumber, $LC.PatientNote, $LC.IsSimilarity, $LC.IsMerged, $LC.Similarity,
            $LC.BasePatient, $LC.InpatientNumber, $LC.ClinicalNumber
        ],

        cols: [
            $LC.GlobalPatientIdWithTag,
            $LC.Name, $LC.Gender, $LC.FullAge, $LC.IDCard, $LC.SocietyNumber, $LC.DateOfBirth, $LC.Telephone,
            $LC.InpatientNumber, $LC.ClinicalNumber, $LC.LastUpdateDateTime, $LC.PatientNote //, $LC.LastUpdateDateTime
        ],
        mergePopCols: [
            $LC.IsMerged, $LC.GlobalPatientId, $LC.Name, $LC.Gender, $LC.FullAge, $LC.IDCard, $LC.SocietyNumber,
            $LC.DateOfBirth, $LC.Similarity, $LC.Telephone, $LC.InpatientNumber, $LC.ClinicalNumber,
            $LC.LastUpdateDateTime
        ],
        detailCols: [
            $LC.BasePatient, $LC.IsMerged,
            $LC.GlobalPatientId, $LC.Name, $LC.Gender, $LC.FullAge, $LC.IDCard, $LC.SocietyNumber, $LC.DateOfBirth,
            $LC.Similarity, $LC.Telephone, $LC.InpatientNumber, $LC.ClinicalNumber,
            $LC.LastUpdateDateTime //, $LC.Telephone, $LC.Address
        ],
        switchOrderCols: [
            $LC.GlobalPatientId, $LC.Name, $LC.Gender, $LC.FullAge, $LC.IDCard, $LC.SocietyNumber, $LC.DateOfBirth,
            $LC.Telephone, $LC.InpatientNumber, $LC.ClinicalNumber, $LC.LastUpdateDateTime
        ]
    },
    PatientInfoHistory: {
        rows: [
            $LC.PatientInfoModifyType,
            $LC.PatientInfoModifyStaff,
            $LC.PatientInfoModifyDateTime,
            $LC.PatientInfoModifyItems,
            $LC_S.Patient_OriginalValue,
            $LC_S.Patient_NowValue
        ],
        cols: [
            $LC_S.Patient_OriginalValue,
            $LC_S.Patient_NowValue,
            $LC.PatientInfoModifyItems,
            $LC.PatientInfoModifyType,
            $LC.PatientInfoModifyStaff,
            $LC.PatientInfoModifyDateTime
        ]
    },
    RegisterList: {
        rows: [
            $LC.OrderId, $LC.GlobalPatientId, $LC.PatientName, $LC.DeviceId,
            $LC.Gender, $LC.PatientType, $LC.ClinicalNumber,
            $LC.InpatientNumber, $LC.InHospitalCount, $LC.AccessionNumber, $LC.HisColumns.HisOrderCode, $LC.IsVIP,
            $LC.ModalityName, $LC.CheckItems, $LC.DiagnosisGroup, $LC.DeviceName, $LC.ApplyDoctor,
            $LC.BodyPartNames, $LC.ExamRoom, $LC.MedicalRecordNumber, $LC.VisitSerialNumber,
            $LC.RegisterTime, $LC.OrginalStatus, $LC.Status,
            $LC.ArriveTime, $LC.RegisterTime, $LC.PatientID, $LC.DisplayAge, $LC.PatientMergeId,
            $LC.Telephone, $LC.IDCard, $LC.SocietyNumber, $LC.EmergencyDegree, $LC.DoctorAdviceType, $LC.IsReportPrinted, $LC.PatientIdentityName, $LC.StudyInstanceUId, $LC.OrginalIsMatch,
            $LC.OrderDepartment, $LC.TotalFee, $LC.ScheduledTimePeriod, $LC.LastImageDateTime, $LC.IsFromHIS, $LC.DateOfBirth,
            $LC.IsMultiple, $LC.QueueNumber
        ],
        cols: [
            $LC.EmergencyDegree,$LC.Status, $LC.AccessionNumber, $LC.GlobalPatientId,
            $LC.PatientName, $LC.Gender, $LC.DisplayAge, $LC.DateOfBirth, $LC.Telephone, $LC.ExamRoom, $LC.CheckItems, $LC.DiagnosisGroup,
            $LC.ArriveTime, $LC.PatientType, $LC.RegisterTime,
            $LC.InpatientNumber, $LC.InHospitalCount, $LC.ClinicalNumber, $LC.IDCard, $LC.SocietyNumber, $LC.BodyPartNames, $LC.ModalityName,
            $LC.OrderDepartment, $LC.TotalFee, $LC.ScheduledTimePeriod, $LC.LastImageDateTime, $LC.QueueNumber
        ],
        predefinedHiddenCols: [
            $LC.PatientIdentityName, $LC.DoctorAdviceType, $LC.MedicalRecordNumber, $LC.VisitSerialNumber
        ],
        enCols: [
            $LC.EmergencyDegree,$LC.HisColumns.HisOrderCode, $LC.Status, $LC.InpatientNumber, $LC.InHospitalCount, $LC.ClinicalNumber, $LC.AccessionNumber, $LC.GlobalPatientId,
            $LC.PatientName, $LC.Gender, $LC.DisplayAge, $LC.IDCard, $LC.SocietyNumber, $LC.BodyPartNames,
            $LC.PatientType, $LC.ModalityName, $LC.ExamRoom, $LC.CheckItems, $LC.ArriveTime, $LC.RegisterTime, $LC.ScheduledTimePeriod, $LC.LastImageDateTime, $LC.QueueNumber
        ]
    },

    ScheduleList: {
        rows: [
            $LC.OrderId, $LC.DeviceId,
            $LC.GlobalPatientId, $LC.PatientName, $LC.Gender, $LC.MedicalRecordNumber, $LC.VisitSerialNumber,
            $LC.PatientType, $LC.ClinicalNumber, $LC.InpatientNumber, $LC.InHospitalCount,
            $LC.AccessionNumber, $LC.HisOrderCode, $LC.IsVIP, $LC.ModalityName, $LC.CheckItems,
            $LC.DeviceName, $LC.ApplyDoctor, $LC.BodyPartNames,
            $LC.ExamRoom, $LC.RegisterTime, $LC.Status,
            $LC.OrginalStatus, $LC.ArriveTime, $LC.ScheduledStartTime,
            $LC.TimePeriod, $LC.PatientId, $LC.PatientID, $LC.DisplayAge, $LC.DateOfBirth,
            $LC.PatientMergeId, $LC.Telephone, $LC.IDCard, $LC.SocietyNumber, $LC.EmergencyDegree,
            $LC.ScheduledTimePeriod, $LC.PatientIdentityName, $LC.DoctorAdviceType,
            $LC.OrderDepartment, $LC.TotalFee, $LC.LastImageDateTime, $LC.IsFromHIS, $LC.QueueNumber
        ],

        cols: [
            $LC.EmergencyDegree, $LC.Status, $LC.AccessionNumber, $LC.GlobalPatientId, $LC.PatientName, $LC.Gender,
            $LC.DisplayAge, $LC.DateOfBirth, $LC.Telephone, $LC.ExamRoom, $LC.CheckItems, $LC.ArriveTime, $LC.PatientType, $LC.ScheduledTimePeriod,
            $LC.RegisterTime, $LC.InpatientNumber, $LC.InHospitalCount, $LC.ClinicalNumber,
            $LC.IDCard, $LC.SocietyNumber, $LC.BodyPartNames, $LC.ModalityName,
            $LC.OrderDepartment, $LC.TotalFee, $LC.LastImageDateTime, $LC.QueueNumber
        ],
        predefinedHiddenCols: [
            $LC.PatientIdentityName, $LC.DoctorAdviceType, $LC.MedicalRecordNumber, $LC.VisitSerialNumber
        ],
        enCols: [
            $LC.EmergencyDegree,$LC.HisColumns.HisOrderCode, $LC.Status, $LC.InpatientNumber, $LC.InHospitalCount, $LC.ClinicalNumber,
            $LC.GlobalPatientId, $LC.PatientName, $LC.Gender,
            $LC.DisplayAge, $LC.DateOfBirth, $LC.Telephone, $LC.IDCard, $LC.SocietyNumber, $LC.BodyPartNames,
            $LC.PatientType, $LC.ModalityName, $LC.ExamRoom, $LC.CheckItems, $LC.ScheduledTimePeriod, $LC.ArriveTime, $LC.RegisterTime, $LC.LastImageDateTime, $LC.QueueNumber
        ]
    },

    ReportList: {
        rows: [
            $LC_S.ReportListIcons, $LC.EmergencyDegree,$LC.DoctorAdviceType,
            $LC.ReportAudioCount, $LC.MedicalRecordNumber, $LC.VisitSerialNumber,
            $LC.OrderId, $LC.ReportId, $LC.AccessionNumber,
            $LC.ApproveDatetime, $LC.ArriveTime, $LC.ApproveDoctor,
            $LC.ClinicalNumber, $LC.Telephone, $LC.Checkitems, $LC.Hospital, $LC.HospitalId,
            $LC.Device, $LC.Gender, $LC.GlobalPatientId,
            $LC.InpatientNumber, $LC.IsLock, $LC.IsPositive,
            $LC.IsVIP, $LC.Keywords, $LC.Modality, $LC.ModalityId, $LC.IsReportPrinted,
            $LC.OrderDepartment, $LC.OrderDoctor, $LC.PatientName, $LC.Birthday,
            $LC.PatientSpellName, $LC.PatientType, $LC.OrginalReportStatus,
            $LC.ReportStatus, $LC.ReportCreator, $LC.ReportCreatorId, $LC.DisplayAge, $LC.ReportTimeSpace, $LC.ICDCode,
            $LC.StudyDateTime, $LC.UploadToRegionTime,
            $LC.PDStatus, $LC.IDCard, $LC.SocietyNumber, $LC.IsCritical,
            $LC.ReportImageReader, $LC.ReportQuality, $LC.ContagionName, $LC.ReportFollowUp, $LC.NeedFollowUp,
            $LC.ImageReaderId, $LC.RegionAssist, $LC.ReportSeq, $LC.DiagnosisGroup, $LC.FilmingRank,
            $LC.ImageCount, $LC.IsPrintFilm, $LC.OrderDepartment, $LC.BodyParts, $LC.StudyDateTime, $LC.OrderDoctor,
            $LC.ApplyDoctor, $LC.CheckInDoctor, $LC.ExecDoctorName, $LC.OrginalIsMatch, $LC.IsMatch, $LC.StudyInstanceUId,
            $LC.AssignedReportDoctor, $LC.AssignedApproveDoctor, $LC.AssignedReportDoctorId, $LC.AssignedApproveDoctorId,
            $LC.Impression, $LC.PatientIdentityName, $LC.LastImageDateTime
        ],
        cols: [
            $LC_S.ReportListIcons, $LC.EmergencyDegree, $LC.PDStatus, $LC.ReportStatus, $LC.IsCritical, $LC.InpatientNumber,
            $LC.AccessionNumber, $LC.GlobalPatientId, $LC.PatientName,
            $LC.Gender, $LC.DisplayAge, $LC.Birthday, $LC.Telephone, $LC.PatientType, $LC.OrderDepartment, $LC.BodyParts, $LC.StudyDateTime,
            $LC.ReportCreator, $LC.AssignedReportDoctor,
            $LC.ApproveDatetime, $LC.ApproveDoctor, $LC.AssignedApproveDoctor,
            $LC.Checkitems, $LC.Keywords, $LC.Device, $LC.FilmingRank,
            $LC.ImageCount, $LC.Modality, $LC.IsPositive,
            $LC.IDCard, $LC.SocietyNumber, $LC.ClinicalNumber, $LC.ArriveTime,
            $LC.ICDCode, $LC.ReportImageReader, $LC.ReportQuality, $LC.ContagionName, $LC.NeedFollowUp,
            $LC.ReportFollowUp, $LC.DiagnosisGroup, $LC.CheckInDoctor, $LC.ExecDoctorName,
            $LC.IsPrintFilm, $LC.OrderDoctor, $LC.Impression, $LC.LastImageDateTime
        ],
        predefinedHiddenCols: [
            $LC.PatientIdentityName, $LC.DoctorAdviceType, $LC.MedicalRecordNumber, $LC.VisitSerialNumber
        ],
        enCols: [
            $LC_S.ReportListIcons, $LC.PDStatus, $LC.RegionAssist, $LC.ReportStatus, $LC.IsCritical,
            $LC.AccessionNumber, $LC.GlobalPatientId, $LC.PatientName,
            $LC.Gender, $LC.DisplayAge, $LC.Modality, $LC.Checkitems, $LC.ApproveDatetime, $LC.StudyDateTime,
            $LC.Device, $LC.PatientType, $LC.IDCard, $LC.SocietyNumber,
            $LC.ClinicalNumber, $LC.InpatientNumber, $LC.ReportCreator, $LC.AssignedReportDoctor,
            $LC.ApproveDoctor, $LC.AssignedApproveDoctor,
            $LC.Keywords, $LC.ICDCode, $LC.ArriveTime,
            $LC.ContagionName, $LC.DiagnosisGroup, $LC.ImageCount,
            $LC.IsPrintFilm, $LC.OrderDepartment, $LC.BodyParts, $LC.OrderDoctor, $LC.Impression
        ]
    },

    PerformList: {
        rows: [
            $LC.OrderId, $LC.GlobalPatientId, $LC.PatientName, $LC.PatientType, $LC.AccessionNumber, $LC.BedNumber, $LC.Status,
            $LC.OrginalStatus, $LC.MedicalRecordNumber, $LC.VisitSerialNumber,
            $LC.Gender, $LC.ArriveTime, $LC.DisplayAge, $LC.DateOfBirth, $LC.PatientIdentityName, $LC.IsMatch, $LC.OrginalIsMatch,
            $LC.DeviceId,
            $LC.ModalityId, $LC.IDCard, $LC.SocietyNumber, $LC.Telephone, $LC.Checkitems, $LC.ExecDoctorName, $LC.FilmingRank, $LC.FilmingFailedReason,
            $LC.EmergencyDegree, $LC.ExecDoctorId, $LC.LastImageDateTime, $LC.IsFromHIS, $LC.ExamConfirm
        ],

        cols: [
            $LC.ExamConfirm, $LC.EmergencyDegree, $LC.PatientName, $LC.AccessionNumber, $LC.GlobalPatientId, $LC.BedNumber,
            $LC.Gender, $LC.DisplayAge, $LC.DateOfBirth, $LC.Telephone, $LC.Checkitems, $LC.ExecDoctorName, $LC.FilmingRank, $LC.FilmingFailedReason,
            $LC.IDCard, $LC.SocietyNumber, $LC.PatientType, $LC.IsMatch, $LC.ArriveTime, $LC.LastImageDateTime
        ], predefinedHiddenCols: [
            $LC.PatientIdentityName, $LC.MedicalRecordNumber, $LC.VisitSerialNumber
        ]
    },
    StatisticDetailsList: {
        rows: [
            $LC.OrderId, $LC.GlobalPatientId, $LC.PatientName,
            $LC.Gender, $LC.PatientType, $LC.ClinicalNumber,
            $LC.InpatientNumber, $LC.AccessionNumber, $LC.IsVIP,
            $LC.ModalityName, $LC.CheckItems, $LC.DeviceName, $LC.ApplyDoctor, $LC.IsPositive,
            $LC.BodyPartNames, $LC.ExamRoom,
            $LC.RegisterTime, $LC.OrginalStatus, $LC.Status,
            $LC.ArriveTime, $LC.RegisterTime, $LC.ScheduledStartTime,
            $LC.TotalCheckFee, $LC.TotalFilmFee, $LC.TotalMaterialFee, $LC.TotalFee,
            $LC.PatientID, $LC.DisplayAge, $LC.PatientMergeId,
            $LC.IDCard, $LC.SocietyNumber
        ],
        cols: [
            $LC.Status, $LC.InpatientNumber, $LC.GlobalPatientId,
            $LC.PatientName, $LC.Gender, $LC.DisplayAge, $LC.IDCard, $LC.SocietyNumber, $LC.IsPositive,
            $LC.BodyPartNames,
            $LC.PatientType, $LC.ModalityName, $LC.ExamRoom, $LC.CheckItems, $LC.ArriveTime, $LC.RegisterTime,
            $LC.ScheduledStartTime,
            $LC.TotalCheckFee, $LC.TotalFilmFee, $LC.TotalMaterialFee, $LC.TotalFee
        ]
    },
    StatisticDiseaseDetailsList: {
        rows: [
            $LC.GlobalPatientId, $LC.AccessionNumber, $LC.PatientName, $LC.StudyDateTime, $LC.Device, $LC.ApproveDoctor
        ],
        cols: [
            $LC.GlobalPatientId, $LC.AccessionNumber, $LC.PatientName, $LC.StudyDateTime, $LC.Device, $LC.ApproveDoctor
        ]
    },
    MakeupList: {
        rows: [$LC.AccessionNumber, $LC.GlobalPatientId, $LC.PatientName, $LC.Gender, $LC.Birthday, $LC.StudyDescription, $LC.ExamineDateTime],
        cols: [$LC.AccessionNumber, $LC.GlobalPatientId, $LC.PatientName, $LC.Gender, $LC.Birthday, $LC.StudyDescription, $LC.ExamineDateTime]
    },
    PrivateTemplateList: {
        rows: [$LC.Id, $LC.TemplateName, $LC.MnemonicCode, $LC.ApplyGender, $LC.BodyPartName, $LC.ModalityName, $LC.DiseaseName, $LC.TemplateBodypartName, $LC.FromOtherNode],
        cols: [$LC.TemplateName, $LC.MnemonicCode, $LC.ApplyGender, $LC.BodyPartName, $LC.ModalityName, $LC.DiseaseName, $LC.TemplateBodypartName]
    },
    PrivateTemplateRegionList:{
        rows: [$LC.Id, $LC.TemplateName, $LC.MnemonicCode, $LC.ApplyGender, $LC.BodyPartName, $LC.ModalityName, $LC.DiseaseName, $LC.TemplateBodypartName, $LC.FromOtherNode],
        cols: [$LC.TemplateName, $LC.MnemonicCode, $LC.ApplyGender, $LC.BodyPartName, $LC.ModalityName, $LC.DiseaseName, $LC.TemplateBodypartName, $LC.FromOtherNode]
    },
    DiagnosisList: {
        rows: [$LC.Id, $LC.CommonName, $LC.DiagnosisMembers, $LC.DiagnosisDevices, $LC.DiagnosisBodyParts, $LC.DiagnosisStatus, $LC.PatientTypes],
        cols: [$LC.CommonName, $LC.DiagnosisMembers, $LC.DiagnosisDevices, $LC.DiagnosisBodyParts, $LC.DiagnosisStatus, $LC.PatientTypes]
    },
    DiagnosisListV2: {
        rows: [$LC.Id, $LC.CommonName, $LC.DiagnosisAssignmentType, $LC.DiagnosisStartDateDiff, $LC.DiagnosisEndDateDiff,$LC.DiagnosisCheckItems, $LC.DiagnosisStartTime, $LC.DiagnosisEndTime, $LC.DiagnosisModalities, $LC.DiagnosisMembers, $LC.DiagnosisDevices, $LC.DiagnosisBodyParts, $LC.DiagnosisStatus, $LC.PatientTypes],
        cols: [$LC.CommonName, $LC.DiagnosisAssignmentType,$LC.DiagnosisCheckItems, $LC.DiagnosisStartTime, $LC.DiagnosisEndTime, $LC.DiagnosisModalities,$LC.DiagnosisStatus, $LC.PatientTypes]
    },
    StatisticReportList: {
        rows: [$LC.Id, $LC.CommonName, $LC.StatisticsCategoryName, $LC.StatisticsIsPublic, $LC.StatisticsOperaterName, $LC.StatisticsCreateDateTime],
        cols: [$LC.CommonName, $LC.StatisticsCategoryName, $LC.StatisticsIsPublic, $LC.StatisticsOperaterName, $LC.StatisticsCreateDateTime]
    },
    AuditList_LoginList: {
        cols: [$LC.AuditColumns.Actioner, $LC.AuditColumns.OperateTime, $LC.AuditColumns.ActionName, $LC.AuditColumns.UserLogin, $LC.AuditColumns.ClientIP],
    },
    AuditList_CreateUserList: {
        cols: [$LC.AuditColumns.Actioner, $LC.AuditColumns.OperateTime, $LC.AuditColumns.ActionName, $LC.AuditColumns.CreateUser, $LC.AuditColumns.ClientIP],
    },
    AuditList_ModifyUserList: {
        cols: [$LC.AuditColumns.Actioner, $LC.AuditColumns.OperateTime, $LC.AuditColumns.ActionName, $LC.AuditColumns.ModifyUser, $LC.AuditColumns.ClientIP],
    },
    AuditList_DeleteUserList: {
        cols: [$LC.AuditColumns.Actioner, $LC.AuditColumns.OperateTime, $LC.AuditColumns.ActionName, $LC.AuditColumns.DeleteUser, $LC.AuditColumns.ClientIP],
    },
    AuditList_ChangePasswordList: {
        cols: [$LC.AuditColumns.Actioner, $LC.AuditColumns.OperateTime, $LC.AuditColumns.ActionName, $LC.AuditColumns.ChangePassword, $LC.AuditColumns.ClientIP],
    },
    AuditList_AssignReportList: {
        cols: [$LC.AuditColumns.Actioner, $LC.AuditColumns.OperateTime, $LC.AuditColumns.ActionName, $LC.AuditColumns.AccessionNumber,
            $LC.AuditColumns.AssignedDoctor, $LC.AuditColumns.CheckItems, $LC.AuditColumns.Hospital, $LC.AuditColumns.ClientIP]
    },
    AuditList_PatientList: {
        cols: [
            $LC.AuditColumns.Actioner, $LC.AuditColumns.OperateTime, $LC.AuditColumns.ActionName,
            $LC.AuditColumns.GloablePatientId, $LC.AuditColumns.PatientName, $LC.AuditColumns.Gender,
            $LC.AuditColumns.Birthday,$LC.AuditColumns.Hospital, $LC.AuditColumns.ClientIP
        ]
    },
    AuditList_OrderList: {
        cols: [
            $LC.AuditColumns.Actioner, $LC.AuditColumns.OperateTime, $LC.AuditColumns.ActionName,
            $LC.AuditColumns.GloablePatientId, $LC.AuditColumns.PatientName, $LC.AuditColumns.Gender,
            $LC.AuditColumns.Birthday,
            $LC.AuditColumns.InpatientNumber, $LC.ClinicalNumber, $LC.AuditColumns.AccessionNumber, $LC.AuditColumns.CheckItems,
            $LC.AuditColumns.Hospital, $LC.AuditColumns.ClientIP
        ]
    },
    AuditList_ReportList: {
        cols: [
            $LC.AuditColumns.Actioner, $LC.AuditColumns.OperateTime, $LC.AuditColumns.ActionName,
            $LC.AuditColumns.GloablePatientId, $LC.AuditColumns.PatientName, $LC.AuditColumns.Gender,
            $LC.AuditColumns.Birthday,
            $LC.AuditColumns.InpatientNumber, $LC.ClinicalNumber, $LC.AuditColumns.AccessionNumber, $LC.AuditColumns.CheckItems,
            $LC.AuditColumns.Findings, $LC.AuditColumns.Impression,
            $LC.AuditColumns.Hospital, $LC.AuditColumns.ClientIP
        ]
    },
    AuditList_ViewImageList: {
        cols: [
            $LC.AuditColumns.Actioner, $LC.AuditColumns.OperateTime, $LC.AuditColumns.ActionName,
            $LC.AuditColumns.GloablePatientId,
            $LC.AuditColumns.InpatientNumber, $LC.ClinicalNumber, $LC.AuditColumns.AccessionNumber,
            $LC.AuditColumns.ClientIP
        ]
    },
    AuditList_AllList: {
        cols: [
            $LC.AuditColumns.Actioner, $LC.AuditColumns.OperateTime, $LC.AuditColumns.ActionName,
            $LC.AuditColumns.UserLogin, $LC.AuditColumns.CreateUser, $LC.AuditColumns.ModifyUser, $LC.AuditColumns.DeleteUser, $LC.AuditColumns.ChangePassword,
            $LC.AuditColumns.GloablePatientId, $LC.AuditColumns.PatientName, $LC.AuditColumns.Gender,
            $LC.AuditColumns.Birthday,
            $LC.AuditColumns.AssignedDoctor,
            $LC.AuditColumns.InpatientNumber, $LC.ClinicalNumber, $LC.AuditColumns.AccessionNumber, $LC.AuditColumns.CheckItems,
            $LC.AuditColumns.Findings, $LC.AuditColumns.Impression,
            $LC.AuditColumns.Hospital, $LC.AuditColumns.ClientIP
        ]
    },
    ReportTemplateList: {
        cols: [
            $LC.TemplateName, $LC.TemplateType, $LC.TemplateCategory, $LC.TemplateStatus, $LC.ModalityName, $LC.ServerNode, $LC.Sort
        ]
    },
    HisOrderList: {
        cols: [
            $LC.HisColumns.Details,
            $LC.HisColumns.HisOrderRequestDate,
            $LC.HisColumns.Name,
            $LC.HisColumns.CheckItems,
            $LC.HisColumns.Fee
        ],
        predefinedHiddenCols: [
            $LC.HisColumns.HisOrderCode,
            $LC.HisColumns.GlobalPatientId,
            $LC.HisColumns.Gender,
            $LC.HisColumns.ApplyDepartment,
            $LC.HisColumns.ApplyDoctor,
            $LC.HisColumns.ScheduleDateTime,
            $LC.HisColumns.Birthday,
            $LC.HisColumns.PatientIdentity,
            $LC.HisColumns.ClinicalDiagnosis,
            $LC.HisColumns.PatientType
        ]
    },
    AutoPrintList: {
        rows: [
            $LC.OrderId, $LC.GlobalPatientId, $LC.PatientName, $LC.DeviceId,
            $LC.Gender, $LC.PatientType, $LC.ClinicalNumber,
            $LC.InpatientNumber, $LC.InHospitalCount, $LC.AccessionNumber, $LC.HisOrderCode, $LC.IsVIP,
            $LC.ModalityName, $LC.CheckItems, $LC.DiagnosisGroup, $LC.DeviceName, $LC.ApplyDoctor,
            $LC.BodyPartNames, $LC.ExamRoom, $LC.MedicalRecordNumber, $LC.VisitSerialNumber,
            $LC.RegisterTime, $LC.OrginalStatus, $LC.Status,
            $LC.ArriveTime, $LC.RegisterTime, $LC.PatientID, $LC.DisplayAge, $LC.PatientMergeId,
            $LC.Telephone, $LC.IDCard, $LC.SocietyNumber, $LC.EmergencyDegree, $LC.DoctorAdviceType, $LC.IsReportPrinted, $LC.PatientIdentityName, $LC.StudyInstanceUId, $LC.OrginalIsMatch,
            $LC.OrderDepartment, $LC.TotalFee, $LC.ScheduledTimePeriod, $LC.LastImageDateTime, $LC.IsFromHIS, $LC.DateOfBirth,
            $LC.IsMultiple
        ],
        cols: [
            $LC.Status, $LC.AccessionNumber, $LC.GlobalPatientId,
            $LC.PatientName, $LC.Gender, $LC.DisplayAge, $LC.DateOfBirth, $LC.Telephone, $LC.ExamRoom, $LC.CheckItems, $LC.DiagnosisGroup,
            $LC.ArriveTime, $LC.PatientType, $LC.RegisterTime,
            $LC.InpatientNumber, $LC.InHospitalCount, $LC.ClinicalNumber, $LC.IDCard, $LC.SocietyNumber, $LC.BodyPartNames, $LC.ModalityName,
            $LC.OrderDepartment, $LC.TotalFee, $LC.ScheduledTimePeriod, $LC.LastImageDateTime
        ],
        predefinedHiddenCols: [
            $LC.PatientIdentityName, $LC.DoctorAdviceType, $LC.MedicalRecordNumber, $LC.VisitSerialNumber
        ],
        enCols: [
            $LC.HisColumns.HisOrderCode, $LC.Status, $LC.InpatientNumber, $LC.InHospitalCount, $LC.ClinicalNumber, $LC.GlobalPatientId,
            $LC.PatientName, $LC.Gender, $LC.DisplayAge, $LC.IDCard, $LC.SocietyNumber, $LC.BodyPartNames,
            $LC.PatientType, $LC.ModalityName, $LC.ExamRoom, $LC.CheckItems, $LC.ArriveTime, $LC.RegisterTime
        ]
    }
};


$LConfig.ReportClinicianList = {
    rows: $LConfig.ReportList.rows,
    cols: [
        $LC_S.ReportListIcons, $LC.EmergencyDegree, $LC.ReportStatus, $LC.IsCritical,
        $LC.AccessionNumber, $LC.GlobalPatientId, $LC.PatientName,
        $LC.Gender, $LC.DisplayAge, $LC.ApplyDoctor, $LC.IDCard, $LC.SocietyNumber, $LC.PatientType,
        $LC.Checkitems, $LC.Device, $LC.StudyDateTime, $LC.Modality,
        $LC.ClinicalNumber, $LC.InpatientNumber, $LC.ReportCreator,
        $LC.ApproveDatetime, $LC.ApproveDoctor, $LC.IsPositive,
        $LC.Keywords, $LC.ICDCode, $LC.ArriveTime,
        $LC.ContagionName, $LC.ImageCount,
        $LC.IsPrintFilm, $LC.OrderDepartment, $LC.BodyParts, $LC.OrderDoctor
    ],
    predefinedHiddenCols: [$LC.PatientIdentityName, $LC.DoctorAdviceType]
};
$LConfig.ReportRegionList = {
    rows: $LConfig.ReportList.rows,
    cols: [
        $LC_S.ReportListIcons, $LC.EmergencyDegree,
        $LC.PDStatus, $LC.ReportStatus, $LC.IsCritical, $LC.InpatientNumber,
        $LC.AccessionNumber, $LC.GlobalPatientId, $LC.PatientName,
        $LC.Gender, $LC.DisplayAge, $LC.Birthday, $LC.Telephone, $LC.PatientType, $LC.OrderDepartment, $LC.BodyParts, $LC.StudyDateTime,
        $LC.ReportCreator, $LC.AssignedReportDoctor, $LC.ApproveDatetime, $LC.ApproveDoctor, $LC.AssignedApproveDoctor, $LC.Checkitems, $LC.Keywords, $LC.Device,
        $LC.ImageCount,
        $LC.Modality, $LC.IsPositive, $LC.RegionAssist, $LC.ReportSeq, $LC.IDCard, $LC.SocietyNumber,
        $LC.ClinicalNumber, $LC.ArriveTime, $LC.UploadToRegionTime, $LC.CheckInDoctor, $LC.ExecDoctorName,
        $LC.ReportImageReader, $LC.ContagionName, $LC.NeedFollowUp, $LC.ReportFollowUp , $LC.DiagnosisGroup, $LC.IsPrintFilm,
        $LC.ICDCode, $LC.OrderDoctor, $LC.Impression, $LC.LastImageDateTime
    ],
    predefinedHiddenCols: [$LC.PatientIdentityName, $LC.DoctorAdviceType, $LC.MedicalRecordNumber, $LC.VisitSerialNumber]
};
$LConfig.ReportRegionCenterList = {
    rows: $LConfig.ReportList.rows,
    cols: [
        $LC_S.ReportListIcons, $LC.EmergencyDegree, $LC.RegionAssist, $LC.Hospital,
        $LC.ReportStatus, $LC.AccessionNumber, $LC.GlobalPatientId, $LC.PatientName,
        $LC.Gender, $LC.DisplayAge, $LC.IDCard, $LC.SocietyNumber, $LC.Checkitems,
        $LC.Device, $LC.StudyDateTime, $LC.Modality, $LC.InpatientNumber, $LC.ClinicalNumber, $LC.ReportCreator,
        $LC.AssignedReportDoctor, $LC.AssignedApproveDoctor, $LC.ApproveDatetime,
        $LC.ApproveDoctor, $LC.DiagnosisGroup, $LC.IsPositive, $LC.Keywords
    ]
};
$LConfig.ReportRegionOrderCenterList = {
    rows: $LConfig.ReportList.rows,
    cols: [
        $LC_S.ReportListIcons4RegionOrder,$LC.Hospital,
        $LC.ReportStatus, $LC.AccessionNumber, $LC.GlobalPatientId, $LC.PatientName,
        $LC.Gender, $LC.DisplayAge, $LC.IDCard, $LC.SocietyNumber, $LC.Checkitems,
        $LC.Device, $LC.StudyDateTime, $LC.Modality, $LC.InpatientNumber, $LC.ClinicalNumber, $LC.ReportCreator,
        $LC.ApproveDatetime,
        $LC.ApproveDoctor, $LC.IsPositive, $LC.Keywords
    ]
};

function getColIndexInColumns(cols, col) {
    var idx = -1;
    if (cols && col) {
        $(cols).each(function(i,item) {
            if (item.key === col.key) {
                idx = i;
                return false;
            }
        });
    }
    return idx;
};


// 生成ligerui适应的数据源
function $LC_GenerateRows(def, data) {
    var jsonData = {};
    jsonData.Rows = [];
    var nowDate = global.systemTime;
    var colorCft = store.get("orderColorSetting");
    if (null == colorCft || undefined == colorCft) {
        colorCft = {};
    }

    var reportColorCft = store.get("reportColorSetting");
    if (null == reportColorCft || undefined == reportColorCft) {
        reportColorCft = {};
    }
    var appSettings = storeManager.Settings.getApplicationSettings();
    var reportTimes = SH.getReportTimes(appSettings);
    var reportTimePrompts = SH.getReportTimePrompts(appSettings);

    function getReportTimeText(remaining) {
        var tpl = '<span style="color:{1}" title="' + lang.msg.ReportMsg18 + '">{0}</span>';
        var color = "";
        $(reportTimePrompts).each(function() {
            if ((this.Min < remaining && remaining <= this.Max) || (this.Min == 0 && remaining == 0)) {
                color = this.Color;
                if (color == "yellow") color = '#FF8000';
                return false;
            }
        });
        if (color == "") color = "green";
        return tpl.format(remaining, color);
    }

    $.each(data, function (i, dataPart) {
        var row = {};
        $.each(def, function (j, item) {
            if (!item) return true;

            // IsVIP
            if (item.key == 'IsVIP') {
                row[item.key] = dataPart[item.key] ? 'VIP' : '';
                return true;
            }
            
            if (item.key == 'AccessionNumber') {
                var accessionNumberHtm = "<span class='list-placeholder'/>" + dataPart[item.key];
                if (dataPart["ParentAccessionNumber"]) {
                    accessionNumberHtm += '<img style="display:inline-block;margin:0 4px 2px 4px;vertical-align:middle;" src="../../Content/site/icons/multi.png" title="{0}"/>'.format(lang.tips.TipChildOrder.format(dataPart["ParentAccessionNumber"]));
                } else if (dataPart["IsMultiple"]) {
                    accessionNumberHtm += '<img style="display:inline-block;margin:0 4px 2px 4px;vertical-align:middle;" src="../../Content/site/icons/multiple.png" title="{0}"/>'.format(lang.tips.TipMutiOrder);
                }
                row[item.key] = accessionNumberHtm;
                row['Orginal' + item.key] = dataPart[item.key];
                return true;
            }

            //IsPositive
            if (item.key == 'IsPositive') {
                if (dataPart['ReportId'])  //只有写过报告的才显示阴阳性值
                {
                    row[item.key] = dataPart[item.key] ? '<b>{0}</b>'.format(lang.term.Positive) : (dataPart[item.key] == false ? lang.term.NotPositive : lang.term.Unknown);
                }
                else
                    row[item.key] = '';
                return true;
            }
            //IsOriginal
            if (item.isOriginal) {
                row['Orginal' + item.key] = dataPart[item.key];
                return true;
            }
            //IsMatch
            if (item.key == 'IsMatch') {
                row[item.key] = dataPart[item.key] ? "<span style='color:green'>{0}</span>".format(lang.status.Matched) : "<span style='color:red'>{0}</span>".format(lang.status.UnMatch);
                return true;
            }

            // 是否为出报告时间
            if (item.key == 'ReportTimeSpace') {
                var studyDate = dataPart['StudyDateTime'];
                if (studyDate === null || 'Verify,Publish,Print'.indexOf(dataPart['ReportStatus']) >= 0) {
                    row[item.key] = '';
                    return true;
                }
                var hasGone = getTimespaceMin(studyDate, nowDate);
                var patientType = dataPart['PatientType'];
                var reportTime = parseInt(reportTimes[patientType]);
                if (isNaN(reportTime)) reportTime = 0;
                var remaining = reportTime - hasGone;
                if (remaining < 0) remaining = 0;
                row[item.key] = getReportTimeText(remaining);
                return true;
            }
            //PDStatus
            if (item.key == 'PDStatus') {
                if (dataPart[item.key] == undefined || dataPart[item.key] == null || dataPart[item.key] == "") {
                    row[item.key] = "Unwritten";
                } else {
                    row[item.key] = dataPart[item.key];
                }
            }
            // 是否为枚举
            if (item.enumVal && item.enumVal == "OrderStatus") {
                var color = colorCft[dataPart[item.key]] ? colorCft[dataPart[item.key]] : "";
                var tmpl = "<span style='width:16px; display:inline-block; height:16px;margin:0 4px 2px 0;vertical-align:middle;background:{0};'/>{1}";
                if (dataPart['IsReportPrinted']) {
                    tmpl += '<img style="display:inline-block;margin:0 4px 2px 4px;vertical-align:middle;" src="../../Content/site/imgs/report_print.png" title="{0}"/>'.format(lang.msg.LockMsg7);
                }
                row[item.key] = tmpl.format(color, Enum.getName(item.enumVal, dataPart[item.key]));
            } else if (item.enumVal && item.enumVal == "ReportStatus") {
                var color = reportColorCft && reportColorCft[dataPart[item.key]] ? reportColorCft[dataPart[item.key]] : "";
                var tmpl = "<span style='width:16px; display:inline-block; height:16px;margin:0 4px 2px 0;vertical-align: middle;background:{0};'/>{1}";
                row[item.key] = tmpl.format(color, Enum.getName(item.enumVal, dataPart[item.key]));
            } else if (item.enumVal == "PatientTypes") {
                var columns = $.trim(dataPart[item.key]) != '' ? dataPart[item.key].split(',') : '';
                row[item.key] = $.map(columns, function (str) {
                    return Enum.getName('PatientType', str);
                }).join(',');
            } else if (item.key == "TotalFee") {
                var fee = dataPart[item.key] == null && isNaN(dataPart[item.key]) ? 0 : dataPart[item.key];
                row[item.key] = Math.round(fee * 100) / 100;
            }
            else
            {
                row[item.key] = typeof item.enumVal != 'undefined' ? Enum.getName(item.enumVal, dataPart[item.key]) : dataPart[item.key];
            }

            if (item.key == "EmergencyDegree") {
                var tempHtml = "<div sort='{1}' title='{0}' style='line-height: 25px; width: 25px; height: 25px; position: relative;'><div style='padding-left:22px'><i style='position: absolute; width:25px; height:0;border-radius: 50%;border-top:dotted 25px; margin: 0 0 1px 1px;color: {2}; background-color: currentColor;'></i></div><div style='padding-left:22px'><p style='position: relative;color: #fff;text-align:center;width:25px;margin-left:2px;font-size: 16px;font-weight: bold;'>{3}</p></div></div>";
                row[item.key] = dataPart[item.key] == 2 ? tempHtml.format(row[item.key], dataPart[item.key], "red", "1") : dataPart[item.key] == 1 ? tempHtml.format(row[item.key], dataPart[item.key], "orange", "2") : tempHtml.format(row[item.key], dataPart[item.key],  "#00a0e9", "3");
            }
            
        });
        jsonData.Rows.push(row);
    });

    return jsonData;
}
// 生成ligerui适应的数据列
function $LC_GenerateColumns(def, listName,colHideFilter) {
    var tableColumns = [];
    var defColone = $.extend(true, [], def);//clone config

    $.each(defColone, function (i, item) {
        if (colHideFilter && colHideFilter(item)) return true;
        if (typeof item == 'undefined') return true;
        if (typeof item.key == 'undefined') {
            tableColumns.push(item);
            return true;
        }

        item["name"] = item.key;
        item["hide"] = parent&&parent.ligerGridCfgManager?
            !parent.ligerGridCfgManager.getColumnVisible(listName, item.key):
            top.ligerGridCfgManager.getColumnVisible(listName, item.key);
        tableColumns.push(item);
        return true;
    });
    return tableColumns;
}
//根据保存的配置显示或者隐藏相应列
function $LC_LoadColumns(columns, listName) {
    if (columns == null || columns == undefined || !$.isArray(columns) || $.trim(listName) == "") {
        return columns;
    }
    $(columns).each(function (i, item) {
        item["hide"] = !top.ligerGridCfgManager.getColumnVisible(listName, item.name);
    });
    return columns;
};

//初始化列显示隐藏数据
function $LC_PrepareListConfiguration(cols, listName) {
    if (cols != null && cols != undefined && $.isArray(cols) &&
        top.ligerGridCfgManager.isListNameExists(listName)) {
        $.each(cols, function () {
            if (!(this.key == undefined || this.key == null || this.key == "")) {
                top.ligerGridCfgManager.toggleColumn(listName, this.key, this.hide);
            }
        });
    }
};

// 全文查询-算子
function $LC_FullTextQueryOperator() {
    var clause = function (rowdata) {
        var key = $("#txtKey").val();
        return gridHelper.isKeywordExistedInRowdata(key, rowdata);
    };
    return clause;
}
// 全文搜索方法
function $LC_DoFullTextQuery() {
    gridHelper.doFullTextQuery($("#datalist"), $LC_FullTextQueryOperator(), GVar.dataSource);
}
// 初始化数据表
function $LC_InitWorklist(queryParms, onBindCompleted) {
    WDlg.show();
    if (GVar.worklist) GVar.worklist.gridheader.find(".l-grid-hd-cell-sort").remove();
    $LC_UpdateInquiry(queryParms, onBindCompleted);
}
// 刷新数据表
function $LC_RefreshWorkList(onBindCompleted) {
    if (typeof GVar == 'undefined') return;
    GVar.worklist = null;
    GVar.dataSource = null;
    WDlg.show();
    pageRender.buildDataTable(GVar.queryParms, onBindCompleted);
};

//export excel
function exportExcelTable(worklist, ignoreCols) {
    var url = "/handlers/ExportHelper.ashx";
    var reg = /</gm;
    var rows = [];
    var headerCells = [];
    $(worklist.columns).each(function () {
        if ($.trim(this.columnname).length == 0 || (ignoreCols && $.trim(this.columnname).length > 0 && ignoreCols[this.columnname]))
            return true;

        if ((!this.issystem || (this.issystem && this.isrownumber)) &&
            (this.hasOwnProperty("hide") ? !this.hide : true)
        ) {
            headerCells.push("<th>{0}</th>".format($.trim(this.display)));
        }
    });
    rows.push("<tr>{0}</tr>".format(headerCells.join("\r\n")));
    $(worklist.data.Rows).each(function () {
        var that = this;
        var cells = [];
        $(worklist.columns).each(function () {
            if ($.trim(this.columnname).length == 0 || (ignoreCols && $.trim(this.columnname).length > 0 && ignoreCols[this.columnname]))
                return true;

            if ((!this.issystem || (this.issystem && this.isrownumber))
                 && (this.hasOwnProperty("hide") ? !this.hide : true)
            ) {
                var cellCtn = worklist._getCellHtml(that, this).replace(/<[^>]*>|<\/[^>]*>/gm, "");
                //Prevent Excel from displaying using scientific notation
                if (/^\d{11,}$/.test(cellCtn)) {
                    cells.push("<td style='mso-number-format:\"\@\";'>{0}</td>".format(ris_utils.htmlEncode(cellCtn)));
                } else {
                    cells.push("<td>{0}</td>".format(ris_utils.htmlEncode(cellCtn)));
                }
                
            }
        });
        rows.push("<tr>{0}</tr>".format(cells.join("\r\n")));
    });

    var data = "<table>{0}</table>".format(rows.join("\r\n")).replace(reg, "[");
    $.post(url, { exportType: "table", content: data }, function (key) {
        if (key) {
            var fileUrl = url + "?key=" + key;
            var exportFrm = $("#frm4xslexport");
            if (exportFrm.size() == 0) {
                $("<iframe style=\"display:none;\" id=\"frm4xslexport\"></iframe>").appendTo($(document.body)).attr("src", fileUrl);
            } else {
                exportFrm.attr("src", fileUrl);
            }
        }
    });
}
// 更新 自定义的查询
function $LC_UpdateInquiry(queryParms, onBindCompleted) {
    GVar.queryParms = queryParms;
    pageRender.buildDataTable(queryParms, onBindCompleted);
}
// 列表加载完数据后执行的事件
function $LC_OnAfterLoadData(configFile, onBindCompleted) {
    if (GVar.dataSource.Rows.length > 0) {
        // Render the list
        if (GVar.worklist) {
            $("#datalist").show();
            GVar.worklist.options.newPage = 1;
            GVar.worklist.set({ data: GVar.dataSource });
        }
        else {
            GVar.worklist = $("#datalist").ligerGrid(configFile);
            //if (typeof GVar.worklist.options.sortName != undefined)
            //    GVar.worklist.options.sortName = null;

            //make sure worklist's event list of dblclickrow has only one event
            //todo $LC_RefreshWorkList need to clear
            if (GVar.worklist.events && GVar.worklist.events.dblclickrow && GVar.worklist.events.dblclickrow.length > 1) {
                while (GVar.worklist.events.dblclickrow.length > 1) {
                    GVar.worklist.events.dblclickrow.pop();
                }
            }
        }
        
        // select row
        if (typeof GVar.actionOrderId != "undefined" && GVar.actionOrderId != null) {
            var row = $("#datalist div:contains('{0}')".format(GVar.actionOrderId));
            if (row.size() > 0) row.parents("tr").click();
            else if (!GVar.worklist.applyGridSelect()) gridHelper.selectFirstRow($("#datalist"));
        }
        else if (!GVar.worklist.applyGridSelect()) {
            gridHelper.selectFirstRow($("#datalist"));
        }
        gridHelper.loadEmptyInfo($("#datalist"), GVar.dataSource.Rows.length == 0);
    } else {//noresult
        if (GVar.worklist) {
            GVar.worklist.set({ data: GVar.dataSource });
        }
        gridHelper.loadEmptyInfo($("#datalist"), GVar.dataSource.Rows.length == 0);
    }
    //$("#pageloading").hide();

    // used to adjust the list style
    $(window).resize();
    // invoke the bind completed event
    if (typeof onBindCompleted == 'function') onBindCompleted();
}

function $LC_ReSelectGridItem() {
    if (GVar.worklist && GVar.worklist.selected.length > 0) {
        GVar.worklist.select(GVar.worklist.selected[0]);
    } else {
        $LC_RefreshWorkList();
    }
};
/*
List Definitions contains:
predefinedHiddenCols:hidden columns,when column contains usersettings's visible list show it in list.otherwise will not show in list
*/
$(function () {
    window.listManager = function () {
        var __serverSettings = {};
        var __cachedListDef = {};
        var __columnFilter = {};
        var that = this;
        var sysHdnColProp = "predefinedHiddenCols";
        var sysHdnCols = null;

        sys_REST.settings.getUserListSettings(function (res) {
            if (res.StatusCode == STATUS.OK) {
                $(res.Data).each(function (i, item) {
                    if (!__serverSettings.hasOwnProperty(item.SettingKey)) {
                        __serverSettings[item.SettingKey] = $.parseJSON(item.Value);
                    }
                });
            }
        });

        var getSysHdnCols4List = function (listName) {
            if ($LConfig.hasOwnProperty(listName)) {
                var listDef = $LConfig[listName];
                return listDef.hasOwnProperty(sysHdnColProp) ? listDef[sysHdnColProp] : [];
            }
            return [];
        };

        var convertCols2Obj = function(cols) {
            var rslt = {};
            $(cols).each(function(i,item) {
                rslt[item.key] = item;
            });
            return rslt;
        };

        var getColumns = function (listName, incSysHdnCols) {
            if ($LConfig.hasOwnProperty(listName)) {
                var colProp = global.isZhCn() ? "cols" : "enCols";
                var listDef = $LConfig[listName];
                var listCols = listDef.hasOwnProperty(colProp) ? listDef[colProp] : [];
                if (colProp == "enCols" && listCols && listCols.length == 0) {
                    listCols = listDef.hasOwnProperty("cols") ? listDef["cols"] : [];
                }

                if (listCols) {
                    if (incSysHdnCols) {
                        var sysHiddenCols = listDef.hasOwnProperty(sysHdnColProp) ? listDef[sysHdnColProp] : [];
                        return sysHiddenCols ? listCols.concat(sysHiddenCols) : listCols;
                    } else {
                        return listCols;
                    }
                }
            }
            return [];
        };

        var filterByInternalFilter = function (lstName,columns) {
            var filter = null;
            if (__columnFilter.hasOwnProperty(lstName) && (filter = __columnFilter[lstName])) {
                return $.map(columns, function (col) {
                    if (!filter.hasOwnProperty(col.key) || filter[col.key]) {
                        return col;
                    }
                });
            }
            return columns;
        };

        //get Hidden columns for list
        this.getSysHdnColsObj = function(lstName) {
            return convertCols2Obj(getSysHdnCols4List(lstName));
        };

        //清理计算的列缓存
        this.clearCache = function () { __cachedListDef = {}; };

        /*
        update serverSettings
        update cache
        */
        this.applySettings = function (lstName, lstDto) {
            if (lstDto) {
                __serverSettings[lstName] = lstDto;
            }
            var cols = getColumns(lstName, true);
            sysHdnCols = convertCols2Obj(getSysHdnCols4List(lstName));
            var setting = null;
            
            if ((setting = __serverSettings[lstName])) {
                //apply settings with cols Hidden Order
                var colOrders = {}, hiddenCols = {}, visibleCols = {};
                $(setting.Order).each(function (i, item) { colOrders[item] = i + 1; });
                $(setting.Hidden).each(function (i, item) { hiddenCols[item] = true; });
                $(setting.Visible).each(function (i, item) { visibleCols[item] = true; });
                
                __cachedListDef[lstName] = $.map(cols, function (item) {
                    var key = item.key;
                    if (sysHdnCols.hasOwnProperty(key)) {
                        if (visibleCols.hasOwnProperty(key)) return item;
                    }else{
                        if (!hiddenCols[key]) {
                            return item;
                        }
                    }
                });

                __cachedListDef[lstName].sort(function (a, b) {
                    return (colOrders.hasOwnProperty(a.key) ? colOrders[a.key] : 0) - (colOrders.hasOwnProperty(b.key) ? colOrders[b.key] : 0);
                });
            } else {
                __cachedListDef[lstName] = $.map(cols, function(item) {
                    if (!sysHdnCols.hasOwnProperty(item.key)) {return item;}
                });
            }
        };

        //获得列表原始定义的列
        this.getListColumnsDefinition = function (lstName) {
            return filterByInternalFilter(lstName,getColumns(lstName,true));
        };

        //获得列表计算后的列
        this.getListColumns = function (lstName) {
            if (lstName === "") return [];
            if (!__cachedListDef.hasOwnProperty((lstName))) {
                that.applySettings(lstName, __serverSettings[lstName]);
            }
            return filterByInternalFilter(lstName,__cachedListDef[lstName].concat([]));
        };

        /*设置列表列的过滤器 
        filter:arrays of ColumnFilters*/
        this.setListColumnFilter = function (lstName, filter) {
            if (filter != null) {
                filter = prepareColumnFilters(filter);
                __columnFilter[lstName] = filter;
            } else {
                delete __columnFilter[lstName];
            }
        };
        /*
        array Of ColumnFilter
        */
        var prepareColumnFilters = function (filter) {
            var obj = {};
            if (!filter) return null;
            $(filter).each(function () {
                if(!this.Enable){
                    obj[this.Column.key] = this.Enable;
                }
            });
            return obj;
        };
        
        this.ColumnFilter = function(cols,enable) {
            this.Column = cols;
            this.Enable = enable;
        };

        //get Predefined hidden cols
        this.getPredefinedHiddenCols = function (lstName) {
            var prop = "predefinedHiddenCols";
            var lst = $LConfig[lstName];
            return (lst && lst.hasOwnProperty(prop)) ? lst[prop] : [];
        };

        //列表设置对象
        this.ListSettingDto = function () {
            this.Hidden = [];
            this.Order = [];
            this.Visible = [];
        };
    };
    window.userListManager = new listManager();
    window.getListSetting = (function () {
        var instance = null;
        var setting = function (lstKey) {
            var node = null;
            var selectorContainer = null;
            var fieldDefinition = null;
            var dialog = null;
            var nodeId = "_fieldDef" + (new Date()).valueOf();
            var dialogHtml = "<div id=\"{0}\"><div class=\"fieldSelector dialogContent\"></div></div>".format(nodeId);
            var listKey = "";
            var sysHdnCols = null; 

            var getDataItemsForSelect = function (dataProvider, bOnlyValue) {
                return $.map(dataProvider(listKey), function (item) {
                    if (bOnlyValue) {
                        return item.key;
                    } else {
                        return { Text: item.display, Value: item.key };
                    }
                });
            };

            var saveListConfig = function (callback, bApply) {
                var cols = new userListManager.ListSettingDto();
                
                $(fieldDefinition.getSelected()).each(function(i, item) {
                    cols.Order.push(item.Value);
                    if (sysHdnCols.hasOwnProperty(item.Value)) {
                        cols.Visible.push(item.Value);
                    }
                });
                $(fieldDefinition.getUnSelected()).each(function (i, item) { cols.Hidden.push(item.Value); });

                var userConfig = {
                    SettingKey: listKey,
                    UserId: SH.getCurrentStaffId(),
                    Value: $.toJSON(cols)
                };

                if (bApply) {
                    sys_REST.settings.modifyListSetting(userConfig, function () { if (callback) callback(listKey, cols); });
                } else {
                    if (callback) callback(listKey, cols);
                }
            };

            var initSelection = function (lstKey) {
                listKey = lstKey;
                fieldDefinition.setData(getDataItemsForSelect(userListManager.getListColumnsDefinition));
            };

            this.init = function (lstKey) {
                node = $(dialogHtml);
                node.appendTo($(document.body));
                selectorContainer = $(".fieldSelector", node);
                fieldDefinition = new leftRightSelector({
                    target: selectorContainer, leftTitle: lang.term.ColumnToSelect, rightTitle: lang.term.ColumnSelected, height: 320, width: 220, validator: function (items) {
                        if (items && items.length == 0) {
                            return { IsValid: false, Message: lang.msg.AtLeastSelectOneItem }
                        }
                        return { IsValid: true, Message: "" }
                    }
                });
                sysHdnCols = userListManager.getSysHdnColsObj(lstKey);
                initSelection(lstKey);
            };

            this.show = function (lstKey) {
                if ($.trim(lstKey) != "" && lstKey != listKey) {
                    initSelection(lstKey);
                }
                
                //get Current selected
                fieldDefinition.setSelected(getDataItemsForSelect(userListManager.getListColumns, true));

                if (dialog == null) {
                    dialog = $.ligerDialog.open(ris_utils.autoResizeDialog({
                        height: 480,
                        target: node,
                        width: 640,
                        title: lang.command.ListSetting,
                        buttons: [{
                            text: lang.command.Save,
                            onclick: function (item, dialog) {
                                saveListConfig(function (lstName, colSetting) {
                                    userListManager.applySettings(lstName, colSetting);
                                    if (onListColumnChanged) onListColumnChanged();
                                    dialog.hide();
                                },true);
                            }
                        },
                        { text: lang.command.Cancel, onclick: function (item, dialog) { dialog.hide(); } }
                        ]
                    }));
                }
                dialog.show();
            };

            if (lstKey) this.init(lstKey);
        };

        return function (lstKey) {
            if (!instance) {
                instance = new setting(lstKey);
            }
            return instance;
        };
    })();
});

